//
//  ViewController.swift
//  MCComponentFunction
//
//  Created by 562863544@qq.com on 11/28/2018.
//  Copyright (c) 2018 562863544@qq.com. All rights reserved.
//

import UIKit

import Photos

import MCComponentPublicUI
import MCComponentFunction

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        title = "示例"
        
        view.addSubview(tableView)
        tableView.snp.remakeConstraints { (make) ->Void in
            make.left.right.top.bottom.equalTo(view)
        }
        
        
        dataArrayM = [
            "倒计时",
            "获取相册所有图片",
            "Toast",
            "时间的转换"
        ]
    }
    
    
    
    lazy var tableView = MCTableView.mc_make(registerCell: UITableViewCell.self, delegate: self)
    
    lazy var dataArrayM: [String] = []
}

extension ViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataArrayM.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell: UITableViewCell = tableView.mc_makeCell(indexPath: indexPath)
        
        cell.textLabel?.text = dataArrayM[indexPath.row]
        
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let titleStr = dataArrayM[indexPath.row]
        
        switch titleStr {
        case "倒计时":
            let vc = MCCountdownViewController()
            navigationController?.pushViewController(vc, animated: true)
        case "获取相册所有图片":
            let vc = ChooseImageViewController()
            navigationController?.pushViewController(vc, animated: true)
            break
        case "Toast":
            let vc = MCToastViewController()
            navigationController?.pushViewController(vc, animated: true)
        case "时间的转换":
            let vc = MCTimeViewController()
            navigationController?.pushViewController(vc, animated: true)

        
        default:
            break
        }
    }
}


